package com.greenx.hello;

import java.text.NumberFormat;

public class HelloRuntime {

	public static void main(String[] args){
		Runtime runtime = Runtime.getRuntime();

	    NumberFormat format = NumberFormat.getInstance();

	    StringBuilder sb = new StringBuilder();
	    long maxMemory = runtime.maxMemory();
	    long allocatedMemory = runtime.totalMemory();
	    long freeMemory = runtime.freeMemory();

	    sb.append("free memory: " + format.format(freeMemory / 1024/1024) + "M<br/>");
	    sb.append("allocated memory: " + format.format(allocatedMemory / 1024/1024) + "M<br/>");
	    sb.append("max memory: " + format.format(maxMemory / 1024/1024) + "M<br/>");
	    sb.append("total free memory: " + format.format((freeMemory + (maxMemory - allocatedMemory)) / 1024/1024) + "M<br/>");
	    
	    System.out.println(sb.toString());
	}
}
